package com.ibm.util.exception;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ibm.util.JSONUtility;

public class CPSException extends Exception {
	private static final long serialVersionUID = -8519131676276734355L;
	private String errMsg;
	private int errCode;

	public CPSException(int code, String message) {
		errMsg = message;
		errCode = code;
	}

	public CPSException(int code, String message, Throwable cause){
		super(cause);
		this.errMsg = message;
		this.errCode = code;
	}

	public int getErrorCode() {
		return errCode;
	}

	public String getErrorMessage() {
		return errMsg;
	}

	@Override
	public String getMessage() {
		ObjectNode errorNode = JSONUtility.newObjectNode();
		errorNode.put("Code", getErrorCode());
		errorNode.put("Message", getErrorMessage());
		return errorNode.toString();
	}

}
